package com.tjtt.tdm.codeReview.action;

import java.sql.RowId;

import com.tjtt.tdm.base.StringUtil;

public class FormHandler {

	/**
	 * 生成列表js
	 * author:lishu	 2014-3-4
	 */
	public static String getTableJS(String formid,String tableid,String columnName,String columnSql,String width,String tablejsid,boolean formstateid){
		String[] columnNames = columnName.split(",");
		String[] widths = width.split(",");
		String colName = "";
		String colModel = "";
		String columns = "";
		for (int i = 0; i < columnNames.length; i++) {
			if(i==columnNames.length-1){
				if(i==0){
					colModel += "{name:'name"+String.valueOf(i)+"',index:'name"+String.valueOf(i)+"', width:"+widths[i]+",key:true,hidden:true,hidedlg:true},";
				}else{
					colModel += "{name:'name"+String.valueOf(i)+"',index:'name"+String.valueOf(i)+"', width:"+widths[i]+"},";
				}
				
			}else{
				if(i==0){
					colModel += "{name:'name"+String.valueOf(i)+"',index:'name"+String.valueOf(i)+"', width:"+widths[i]+",key:true,hidden:true,hidedlg:true},\n";
				}else{
					colModel += "{name:'name"+String.valueOf(i)+"',index:'name"+String.valueOf(i)+"', width:"+widths[i]+"},\n";
				}
			}
			columns += "name"+String.valueOf(i) + ",";
		}
		if(colModel.length()>0){
			colModel = colModel.substring(0,colModel.length()-1);
		}
		if(columns.length()>0){
			columns = columns.substring(0,columns.length()-1);
		}
		StringBuffer sb = new StringBuffer();
		sb.append("$(\"#gridTable"+tableid+"\").jqGrid({\n");
		sb.append("	url:'auto!queryAutoPageData.action',\n");
		sb.append("	datatype: \"json\",\n");
		sb.append("	height: 200,\n");
		sb.append("	width: 800, \n");
		sb.append("	colNames:["+columnName+"],\n");
		sb.append("	colModel:["+colModel+"],\n");
		sb.append("	shrinkToFit:false,\n");
		sb.append("	sortname:'id',\n");
		sb.append("	sortable: false,\n");
		//sb.append("	sortorder:'desc',\n");
		sb.append("	viewrecords:true,\n");
//		sb.append("	multiselect: true,\n");
//		sb.append("	multiboxonly : true,\n ");
		sb.append("	gridview: true,\n");
		sb.append("	rowNum:200,\n");
		sb.append("	rowList:[15,20,50,200,500],\n");
		sb.append("	jsonReader: {\n");
		sb.append("		root:\"rows\",		\n");
		sb.append("		page: \"page\",  	\n");
		sb.append("		total: \"total\",  \n");
		sb.append("		records: \"records\",\n");
		sb.append("		repeatitems : false\n");
		sb.append("	},\n");
		sb.append(" prmNames:{rows:\"rows\",page:\"page\",sort:\"sidx\",order:\"sord\",search:\"search\"},\n");
		sb.append("	pager:\"#gridPager"+tableid+"\",\n");
		sb.append("postData : {\n");
		if(formstateid){
			sb.append("	formstateid:\"true\",\n");
		}else{
			sb.append("	formstateid:\"false\",\n");
		}
		if(!StringUtil.isEmpty(tablejsid)){
			sb.append("	tablejsid:\""+tablejsid+"\",\n");
		}else{
			sb.append("	tablejsid:\"0\",\n");
		}
		sb.append("	formid:\""+formid+"\"\n");
		sb.append("},\n");
		sb.append("	caption: \"\"\n");
		sb.append("});\n");
		return sb.toString();
	}
	/**
	 * 项目分配列表
	 * author:lishu	 2014-3-9
	 */
	public static String getDeptTable(String mainid){
		StringBuffer sb = new StringBuffer();
		sb.append("$(\"#gridTableDept\").jqGrid({\n");
		sb.append("	url:common_basePath+'project/item!queryItem.action?mainid="+mainid+"',\n");
		sb.append("	datatype: \"json\",\n");
		sb.append("	height: 150,\n");
		sb.append("	width: 800, \n");
		sb.append("	colNames:['主键','项目组','样品编号','检测室','所选部门','项目位置','室主任','值班人'],\n");
		sb.append("	colModel:[\n");
		sb.append("		{name:'T_XMZID',index:'T_XMZID', width:70,key:true,hidden:true}, \n");
		sb.append("		{name:'T_XMZ',index:'T_XMZ', width:70}, \n");
		sb.append("		{name:'SAMPLE_NO',index:'SAMPLE_NO', width:70}, \n");
		sb.append("		{name:'T_JCS',index:'T_JCS', width:70}, \n");
		sb.append("		{name:'DEPT_ID',index:'DEPT_ID', width:70}, \n");
		sb.append("		{name:'PROJECT_STATE',index:'PROJECT_STATE', width:70}, \n");
		sb.append("		{name:'SHIZRUSERID',index:'SHIZRUSERID', width:70},\n");
		sb.append("		{name:'ZHIBRUSERID',index:'ZHIBRUSERID', width:70}\n");
		sb.append("	],   \n");
		sb.append("	shrinkToFit:false,\n");
		sb.append("	sortname:'T_XMZID',\n");
		sb.append("	sortorder:'desc',\n");
		sb.append("	viewrecords:true,\n");
		sb.append("	multiselect: true, // 是否显示复选框\n");
		sb.append("	multiboxonly : true, \n");
		sb.append("	rownumbers: false,//显示行号\n");
		sb.append(" cellEdit: true,\n");
		sb.append("	forceFit : true, \n");
		sb.append("	afterEditCell: function (id,name,val,iRow,iCol){	\n");
		sb.append("	},\n");
		sb.append("	afterSaveCell : function(rowid,name,val,iRow,iCol) {\n");
		sb.append("	},\n");
		sb.append("	rowNum:200,\n");
		sb.append("	mtype: \"POST\", \n");
		sb.append("	rowList:[15,20,50,200,500],\n");
		sb.append("	toolbar: [false,\"top\"],\n");
		sb.append("	jsonReader: {\n");
		sb.append("		root:\"rows\",		// 数据行（默认为：rows）\n");
		sb.append("		page: \"page\",  	// 当前页\n");
		sb.append("		total: \"total\",  // 总页数\n");
		sb.append("		records: \"records\",  // 总记录数\n");
		sb.append("		repeatitems : false		// 设置成false，在后台设置值的时候，可以乱序。且并非每个值都得设\n");
		sb.append("	},\n");
		sb.append("	prmNames:{rows:\"rows\",page:\"page\",sort:\"sidx\",order:\"sord\",search:\"search\"},\n");
		sb.append("	pager:\"#gridPagerDept\",\n");
		sb.append("	caption: \"项目列表\"\n");
		sb.append("});\n");
//		sb.append("jQuery(\"#gridTableDept\").jqGrid('filterToolbar');\n");
		//sb.append(" jQuery(\"#gridTable\").jqGrid('filterToolbar');\n");
		sb.append("jQuery(\"#gridTableDept\").jqGrid('filterToolbar'); \n");



		return sb.toString();
	} 
	/**
	 * 项目分配列表查看
	 * author:lishu	 2014-3-9
	 */
	public static String getDeptTable1(String mainid){
		StringBuffer sb = new StringBuffer();
		sb.append("$(\"#gridTableDept\").jqGrid({\n");
		sb.append("	url:common_basePath+'project/item!queryItem.action?mainid="+mainid+"&view=1',\n");
		sb.append("	datatype: \"json\",\n");
		sb.append("	height: 150,\n");
		sb.append("	width: 800, \n");
		sb.append("	colNames:['主键','项目组','样品编号','检测室','所选部门','项目位置','室主任','值班人'],\n");
		sb.append("	colModel:[\n");
		sb.append("		{name:'T_XMZID',index:'T_XMZID', width:70,key:true,hidden:true}, \n");
		sb.append("		{name:'T_XMZ',index:'T_XMZ', width:70}, \n");
		sb.append("		{name:'SAMPLE_NO',index:'SAMPLE_NO', width:70}, \n");
		sb.append("		{name:'T_JCS',index:'T_JCS', width:70}, \n");
		sb.append("		{name:'DEPT_ID',index:'DEPT_ID', width:70}, \n");
		sb.append("		{name:'PROJECT_STATE',index:'PROJECT_STATE', width:70}, \n");
		sb.append("		{name:'SHIZRUSERID',index:'SHIZRUSERID', width:70},\n");
		sb.append("		{name:'ZHIBRUSERID',index:'ZHIBRUSERID', width:70}\n");
		sb.append("	],   \n");
		sb.append("	shrinkToFit:false,\n");
		sb.append("	sortname:'T_XMZID',\n");
		sb.append("	sortorder:'desc',\n");
		sb.append("	viewrecords:true,\n");
		sb.append("	multiselect: true, // 是否显示复选框\n");
		sb.append("	multiboxonly : true, \n");
		sb.append("	rownumbers: false,//显示行号\n");
		sb.append(" cellEdit: true,\n");
		sb.append("	forceFit : true, \n");
		sb.append("	afterEditCell: function (id,name,val,iRow,iCol){	\n");
		sb.append("	},\n");
		sb.append("	afterSaveCell : function(rowid,name,val,iRow,iCol) {\n");
		sb.append("	},\n");
		sb.append("	rowNum:200,\n");
		sb.append("	mtype: \"POST\", \n");
		sb.append("	rowList:[15,20,50,200,500],\n");
		sb.append("	toolbar: [false,\"top\"],\n");
		sb.append("	jsonReader: {\n");
		sb.append("		root:\"rows\",		// 数据行（默认为：rows）\n");
		sb.append("		page: \"page\",  	// 当前页\n");
		sb.append("		total: \"total\",  // 总页数\n");
		sb.append("		records: \"records\",  // 总记录数\n");
		sb.append("		repeatitems : false		// 设置成false，在后台设置值的时候，可以乱序。且并非每个值都得设\n");
		sb.append("	},\n");
		sb.append("	prmNames:{rows:\"rows\",page:\"page\",sort:\"sidx\",order:\"sord\",search:\"search\"},\n");
		sb.append("	pager:\"#gridPagerDept\",\n");
		sb.append("	caption: \"项目列表\"\n");
		sb.append("});\n");
//		sb.append("jQuery(\"#gridTableDept\").jqGrid('filterToolbar');\n");
		//sb.append(" jQuery(\"#gridTable\").jqGrid('filterToolbar');\n");
		sb.append("jQuery(\"#gridTableDept\").jqGrid('filterToolbar'); \n");



		return sb.toString();
	} 
	/**
	 * 人员分配列表
	 * author:lishu	 2014-3-9
	 */
	public static String getUserTable(String mainid,String deptid,String deptseq){
		StringBuffer sb = new StringBuffer();
		//if ("296".equals(deptid)) {
			sb.append("$(\"#gridTableUser\").jqGrid({\n");
			sb.append("	url:common_basePath+'project/item!queryUserItem.action?mainid="+mainid+"&deptseq="+deptseq+"',\n");
			sb.append("	datatype: \"json\",\n");
			sb.append("	height: 150,\n");
			sb.append("	width: 800, \n");
			sb.append("	colNames:['ID','样品编号','检验项目','项目组','检测室','所选部门','所选用户','是否提交'],\n");
			sb.append("	colModel:[\n");
			sb.append("	{name:'ID',index:'ID', width:40,key:true,hidden:true,hidedlg:true}, \n");
			sb.append("		{name:'SAMPLE_NO',index:'SAMPLE_NO', width:70}, \n");
			sb.append("		{name:'T_JYXM',index:'T_JYXM', width:100}, \n");
			sb.append("		{name:'T_XMZ',index:'T_XMZ', width:70},\n");
			sb.append("		{name:'T_JCS',index:'T_JCS', width:70}, \n");
			sb.append("		{name:'DEPT_ID',index:'DEPT_ID', width:70}, \n");
			sb.append("		{name:'USER_ID',index:'USER_ID', width:70},\n");
			sb.append("		{name:'state',index:'state', width:70}\n");
			sb.append("	],   \n");
			sb.append("	shrinkToFit:false,\n");
			sb.append("	sortname:'ID',\n");
			sb.append("	sortorder:'desc',\n");
			sb.append("	viewrecords:true,\n");
			sb.append("	multiselect: true, // 是否显示复选框\n");
			sb.append("	multiboxonly : true, \n");
			sb.append("	rownumbers: false,//显示行号\n");
			sb.append("	onSelectRow: function (rowid, status) {\n");
			sb.append("		var row = jQuery(\"#gridTableUser\").jqGrid('getRowData',rowid);//获取选中行.\n");
			sb.append("		if(row.state==\"已提交\"){\n");
			sb.append("		$(\"#gridTableUser\").setSelection(rowid,false);\n");
			sb.append("		}\n");
			sb.append("	},\n");
			sb.append("	onSelectAll: function (aRowids, status) {\n");
			sb.append("		aRowids = aRowids+\"\"; \n");
			sb.append("		var arr = aRowids.split(\",\"); \n");
			sb.append("		for(var i =0;i<arr.length;i++){ \n");
			sb.append("		  var row = jQuery(\"#gridTableUser\").jqGrid('getRowData',arr[i]);//获取选中行.\n");
			sb.append("		  if(row.state==\"已提交\"){\n");
			sb.append("		    $(\"#gridTableUser\").setSelection(arr[i],false);\n");
			sb.append("		  }\n");
			sb.append("		}\n");
			sb.append("	},\n");
			sb.append("	editable:true, \n");
			sb.append("	rowNum:200,\n");
			sb.append("	rowList:[15,20,50,200,500],\n");
			sb.append("	toolbar: [false,\"top\"],\n");
			sb.append("	jsonReader: {\n");
			sb.append("		root:\"rows\",		// 数据行（默认为：rows）\n");
			sb.append("		page: \"page\",  	// 当前页\n");
			sb.append("		total: \"total\",  // 总页数\n");
			sb.append("		records: \"records\",  // 总记录数\n");
			sb.append("		repeatitems : false		// 设置成false，在后台设置值的时候，可以乱序。且并非每个值都得设\n");
			sb.append("	},\n");
			sb.append("	prmNames:{rows:\"rows\",page:\"page\",sort:\"sidx\",order:\"sord\",search:\"search\"},\n");
			sb.append("	pager:\"#gridPagerUser\",\n");
			sb.append("postData : {\n");
			sb.append("	deptseq:\""+deptseq+"\"\n");
			sb.append("},\n");
			sb.append("	caption: \"项目列表\"\n");
			sb.append("});\n");
			sb.append("$(\"#gridTableUser\").jqGrid('navGrid','#gridPagerUser',{ edit: false, add: false, del: false, refresh: false,search:false});  \n");
			sb.append("jQuery(\"#gridTableUser\").jqGrid('navButtonAdd','#gridPagerUser',{caption:\"未分配人员全选\",onClickButton:function(){ \n");
			sb.append(" var s = $(\"#gridTableUser\").jqGrid('getDataIDs')+\"\"; \n");
			sb.append("if(s){  \n");
			sb.append(" var arr = s.split(\",\"); \n");
			sb.append("  var list = \"\"; \n");
			sb.append("    for(var i=0;i<arr.length;i++){ \n");
			sb.append("       var id = arr[i]; \n");
			sb.append("        var row = $(\"#gridTableUser\").jqGrid('getRowData',id); \n");
			sb.append("         if( null==row.USER_ID || \"\"==row.USER_ID){ \n");
			sb.append("       	 $(\"#gridTableUser\").setSelection(id);\n");
			sb.append("       	} \n");
	               
			sb.append("     } \n");
			sb.append("    }  }    } );\n");
			sb.append("deptUsers('"+deptid+"');\n");
			return sb.toString();
//		}else{
//			sb.append("$(\"#gridTableUser\").jqGrid({\n");
//			sb.append("	url:common_basePath+'project/item!queryUserItemOther.action?mainid="+mainid+"&deptseq="+deptseq+"',\n");
//			sb.append("	datatype: \"json\",\n");
//			sb.append("	height: 150,\n");
//			sb.append("	width: 800, \n");
//			/*sb.append("	colNames:['ID','样品编号','检验项目','项目组','检测室','所选部门','所选用户'],\n");
//			sb.append("	colModel:[\n");
//			sb.append("	{name:'ID',index:'ID', width:40,key:true,hidden:true,hidedlg:true}, \n");
//			sb.append("		{name:'SAMPLE_NO',index:'SAMPLE_NO', width:70}, \n");
//			sb.append("		{name:'T_JYXM',index:'T_JYXM', width:100}, \n");
//			sb.append("		{name:'T_XMZ',index:'T_XMZ', width:70},\n");
//			sb.append("		{name:'T_JCS',index:'T_JCS', width:70}, \n");
//			sb.append("		{name:'DEPT_ID',index:'DEPT_ID', width:70}, \n");
//			sb.append("		{name:'USER_ID',index:'USER_ID', width:70}\n");
//			sb.append("	],   \n");*/
//			sb.append("	colNames:['项目组','项目组','样品编号','检测室','所选部门','所选用户','所选用户'],\n");
//			sb.append("	colModel:[\n");
//			sb.append("	{name:'T_XMZ',index:'T_XMZ', width:40,key:true,hidden:true,hidedlg:true}, \n");
//			sb.append("		{name:'T_XMZ1',index:'T_XMZ1', width:70}, \n");
//			sb.append("		{name:'SAMPLE_NO',index:'SAMPLE_NO', width:100}, \n");
//			sb.append("		{name:'T_JCS',index:'T_JCS', width:70},\n");
//			sb.append("		{name:'DEPT_ID',index:'DEPT_ID', width:70}, \n");
//			sb.append("		{name:'USER_ID',index:'USER_ID', width:70}, \n");
//			sb.append("		{name:'USER_ID1',index:'USER_ID1', width:70,hidden:true}\n");
//			sb.append("	],   \n");
//			sb.append("	shrinkToFit:false,\n");
//			sb.append("	sortname:'T_XMZ',\n");
//			sb.append("	sortorder:'desc',\n");
//			sb.append("	viewrecords:true,\n");
//			sb.append("	multiselect: true, // 是否显示复选框\n");
//			sb.append("	multiboxonly : true, \n");
//			sb.append("	rownumbers: false,//显示行号\n");
//			sb.append("	editable:true, \n");
//			sb.append("	rowNum:200,\n");
//			sb.append("	rowList:[15,20,50,200,500],\n");
//			sb.append("	toolbar: [false,\"top\"],\n");
//			sb.append("	jsonReader: {\n");
//			sb.append("		root:\"rows\",		// 数据行（默认为：rows）\n");
//			sb.append("		page: \"page\",  	// 当前页\n");
//			sb.append("		total: \"total\",  // 总页数\n");
//			sb.append("		records: \"records\",  // 总记录数\n");
//			sb.append("		repeatitems : false		// 设置成false，在后台设置值的时候，可以乱序。且并非每个值都得设\n");
//			sb.append("	},\n");
//			sb.append("	prmNames:{rows:\"rows\",page:\"page\",sort:\"sidx\",order:\"sord\",search:\"search\"},\n");
//			sb.append("	pager:\"#gridPagerUser\",\n");
//			sb.append("postData : {\n");
//			sb.append("	deptseq:\""+deptseq+"\"\n");
//			sb.append("},\n");
//			sb.append("	caption: \"项目列表\"\n");
//			sb.append("});\n");
//			//sb.append("$(\"#gridTableUser\").append(\"<input type='button'  value='编辑原始记录' onclick='openYsjl('1')' style='height:25px;font-size:-3'/>\");\n");
//			//sb.append("  $(\"#gridTableUser\").jqGrid('navButtonAdd', '#gridPagerUser', { caption: 'jstGridSave', onClickButton: function() {  } });  \n");
//			
//			sb.append("$(\"#gridTableUser\").jqGrid('navGrid','#gridPagerUser',{ edit: false, add: false, del: false, refresh: false,search:false});  \n");
//			sb.append("jQuery(\"#gridTableUser\").jqGrid('navButtonAdd','#gridPagerUser',{caption:\"未分配人员全选\",onClickButton:function(){ \n");
//			sb.append(" var s = $(\"#gridTableUser\").jqGrid('getDataIDs')+\"\"; \n");
//			sb.append("if(s){  \n");
//			sb.append(" var arr = s.split(\",\"); \n");
//			sb.append("  var list = \"\"; \n");
//			sb.append("    for(var i=0;i<arr.length;i++){ \n");
//			sb.append("       var id = arr[i]; \n");
//			sb.append("        var row = $(\"#gridTableUser\").jqGrid('getRowData',id); \n");
//			sb.append("         if( null==row.USER_ID || \"\"==row.USER_ID){ \n");
//			sb.append("       	 $(\"#gridTableUser\").setSelection(id);\n");
//			sb.append("       	} \n");
//	               
//			sb.append("     } \n");
//			sb.append("    }  }    } );\n");
//			sb.append("deptUsers('"+deptid+"');\n");
//			return sb.toString();
//		}
//		
	}
	/**
	 * 人员分配列表
	 * author:lishu	 2014-3-9
	 */
	public static String getUserTable1(String mainid,String deptid,String deptseq){
		StringBuffer sb = new StringBuffer();
		sb.append("$(\"#gridTableUser\").jqGrid({\n");
		sb.append("	url:common_basePath+'project/item!queryUserItem.action?mainid="+mainid+"&deptseq="+deptseq+"&view=1',\n");
		sb.append("	datatype: \"json\",\n");
		sb.append("	height: 150,\n");
		sb.append("	width: 800, \n");
		sb.append("	colNames:['ID','样品编号','检验项目','项目组','检测室','所选部门','所选用户'],\n");
		sb.append("	colModel:[\n");
		sb.append("	{name:'ID',index:'ID', width:40,key:true,hidden:true,hidedlg:true}, \n");
		sb.append("		{name:'SAMPLE_NO',index:'SAMPLE_NO', width:70}, \n");
		sb.append("		{name:'T_JYXM',index:'T_JYXM', width:100}, \n");
		sb.append("		{name:'T_XMZ',index:'T_XMZ', width:70},\n");
		sb.append("		{name:'T_JCS',index:'T_JCS', width:70}, \n");
		sb.append("		{name:'DEPT_ID',index:'DEPT_ID', width:70}, \n");
		sb.append("		{name:'USER_ID',index:'USER_ID', width:70}\n");
		sb.append("	],   \n");
		sb.append("	shrinkToFit:false,\n");
		sb.append("	sortname:'ID',\n");
		sb.append("	sortorder:'desc',\n");
		sb.append("	viewrecords:true,\n");
		sb.append("	multiselect: true, // 是否显示复选框\n");
		sb.append("	multiboxonly : true, \n");
		sb.append("	rownumbers: false,//显示行号\n");
		
		sb.append("	editable:true, \n");
		sb.append("	rowNum:200,\n");
		sb.append("	rowList:[15,20,50,200,500],\n");
		sb.append("	toolbar: [false,\"top\"],\n");
		sb.append("	jsonReader: {\n");
		sb.append("		root:\"rows\",		// 数据行（默认为：rows）\n");
		sb.append("		page: \"page\",  	// 当前页\n");
		sb.append("		total: \"total\",  // 总页数\n");
		sb.append("		records: \"records\",  // 总记录数\n");
		sb.append("		repeatitems : false		// 设置成false，在后台设置值的时候，可以乱序。且并非每个值都得设\n");
		sb.append("	},\n");
		sb.append("	prmNames:{rows:\"rows\",page:\"page\",sort:\"sidx\",order:\"sord\",search:\"search\"},\n");
		sb.append("	pager:\"#gridPagerUser\",\n");
		sb.append("postData : {\n");
		sb.append("	deptseq:\""+deptseq+"\"\n");
		sb.append("},\n");
		sb.append("	caption: \"项目列表\"\n");
		sb.append("});\n");
		sb.append("deptUsers('"+deptid+"');\n");
		return sb.toString();
	}
	/**
	 * 获取js方法
	 * author:lishu	 2014-3-9
	 */
	public static String getJsFunction(String mainid){
		StringBuffer sb = new StringBuffer();
		//值班人
		sb.append("		function zhiBanRen() {\n");
		sb.append("			var ids = $(\"#gridTableDept\").jqGrid(\"getGridParam\", \"selarrrow\") + \"\";\n");
		sb.append("		    if (!ids) {\n");
		sb.append("		    alert(\"请先选择记录!\");  \n");
		sb.append("		       return false;  \n");
		sb.append("			} \n");
		sb.append("		     var ids1 = jQuery(\"#gridTableDept\").jqGrid('getDataIDs')+\"\"; \n");
		sb.append("		 	 if( ids1!=\"\" ){ \n");
		sb.append("					var arr = ids.split(\",\");\n");
		sb.append("						var jcsarr= new Array() ;\n");
		sb.append("						var xmzarr= new Array() ;\n");
		sb.append("					 	for(var i=0;i<arr.length;i++){\n");
		sb.append("					 	    var row = jQuery(\"#gridTableDept\").jqGrid('getRowData',arr[i]);//获取选中行.\n");
		sb.append("			 			    var jcs = row.T_JCS;\n");
		sb.append("			 			    var xmz = row.T_XMZ;\n");
		sb.append("                          jcsarr.push(jcs);\n");
		sb.append("                          xmzarr.push(xmz);\n");
		sb.append("							var projectState = row.PROJECT_STATE;\n");
		sb.append("							if(projectState!=\"调度\"  ){\n");
		sb.append("								alert(\"项目位置为调度的才可以分配!\");\n");
		sb.append("	                            return false;\n");
		sb.append("							}\n");
		sb.append("						}\n");
		sb.append("			         var a = jcsarr[0];\n");
		sb.append("					for(var i=1; i < jcsarr.length; i++)  {\n");
		sb.append("						var b = jcsarr[i];\n");
		sb.append("						if(a!=b) {\n");
		sb.append("		 					  alert(\"请选择相同检测室!\");\n");
		sb.append("							  return false; \n");
											
		sb.append("						}\n");
		sb.append("					}\n");
		sb.append("		 	 }\n");
		sb.append("	    var jcs = encodeURIComponent(encodeURIComponent(jcsarr[0]));\n");
		sb.append("	    var toUrl = common_basePath+\"/item!queryJcs.action?mainid="+mainid+"&ids=\"+encodeURIComponent(encodeURIComponent(xmzarr))+\"&jcs=\"+jcs+\"\"; \n");
		sb.append("     var temp =window.showModalDialog(toUrl,null,\"dialogWidth=600px;dialogHeight=300px;\");\n");
//		sb.append("	$.dialog({ \n");
//		sb.append("		        title: '表单信息添加', \n");
//		sb.append("		        content: 'url:"+contextPath+"/project/item!queryJcs.action?ids='+ids+'&jcs='+jcsarr[0], \n");
//		sb.append("		        okVal: false,//确定按钮文字 \n");
//		sb.append("		        cancelVal: false,//取消按钮文字 \n");
//		sb.append("		        min: true, //是否显示最小化按钮 \n");
//		sb.append("		        max: false,//是否显示最大化按钮 \n");
//		sb.append("		        fixed: false,//开启静止定位 \n");
//		sb.append("		        lock: true,//开启锁屏 \n");
//		sb.append("		        focus: true,//弹出窗口后是否自动获取焦点（4.2.0新增） \n");
//		sb.append("		        time: null,//设置对话框显示时间 \n");
//		sb.append("		        resize: true,//是否允许用户调节尺寸 \n");
//		sb.append("		        drag: true,//是否允许用户拖动位置 \n");
//		sb.append("		        cache: false,//是否缓存iframe方式加载的窗口内容页 \n");
//		sb.append("		        width: 1000, \n");
//		sb.append("		        height: 500 \n");
//		sb.append("			}); \n");
		
		sb.append("jQuery(\"#gridTableDept\").jqGrid('setGridParam',\n");	
		sb.append("{\n");	
		sb.append("    url:'project/item!queryItem.action?mainid="+mainid+"'\n");	
		sb.append("}).trigger(\"reloadGrid\", [{page:1}]); \n");	
		sb.append("} \n");	

		//自动分配
		sb.append("	function fenpeiZiDongItem(){\n");
		sb.append("			var ids = $(\"#gridTableDept\").jqGrid(\"getGridParam\", \"selarrrow\") + \"\";\n");
		sb.append("		    if (!ids) {\n");
		sb.append("		    alert(\"请先选择记录!\");  \n");
		sb.append("		       return false;  \n");
		sb.append("			} \n");
		
		sb.append("			if(!confirm(\"是否确认分配 ？\")){\n");
		sb.append("				   return false;\n");
		sb.append("			}\n");	
		sb.append("		     var ids1 = jQuery(\"#gridTableDept\").jqGrid('getDataIDs')+\"\"; \n");
		sb.append("		 	 if( ids1!=\"\" ){ \n");
		sb.append("					var arr = ids.split(\",\");\n");
		sb.append("					 	for(var i=0;i<arr.length;i++){\n");
		sb.append("					 		var row = jQuery(\"#gridTableDept\").jqGrid('getRowData',arr[i]);//获取选中行.\n");
		sb.append("			 				var deptId = row.DEPT_ID;\n");
		sb.append("							var projectState = row.PROJECT_STATE;\n");
		sb.append("							var ZHIBRUSERID = row.ZHIBRUSERID;\n");
		sb.append("							if(deptId!=\"\" && deptId!=null){\n");
		sb.append("		 						alert(\"存在已经分配的部门!\");\n");
		sb.append("		 						return false;\n");
		sb.append("		 					}\n");
		sb.append("							if(projectState!=\"调度\"  ){\n");
		sb.append("								alert(\"项目位置为调度的才可以分配!\");\n");
		sb.append("	                            return false;\n");
		sb.append("							}\n");
		sb.append("							if(ZHIBRUSERID==\"\"  ){\n");
		sb.append("								alert(\"请先分配值班人!\");\n");
		sb.append("	                            return false;\n");
		sb.append("							}\n");
		sb.append("						}\n");
		sb.append("		 	 }\n");
		
		
		sb.append("			 var params = {  \n");
		sb.append("			        \"ids\": ids,\n");
		sb.append("			        \"flag\": 1,\n");
		sb.append("			        \"orgid\" : $(\"#orgId\").val()\n");
		sb.append("			 };  \n");
		sb.append("			 var actionUrl = common_basePath+\"project/item!fenpeiDept.action\"; \n"); 
		sb.append("				    $.ajax({  \n");
		sb.append("				        url : actionUrl,  \n");
		sb.append("				        type : \"post\", \n");
		sb.append("				        data : params,  \n");
		sb.append("				        dataType : \"json\",  \n");
		sb.append("				        cache : false,  \n");
		sb.append("				    error : function(textStatus, errorThrown) {  \n");
		sb.append("				        alert(\"系统ajax交互错误: \" + textStatus.value);  \n");
		sb.append("				    },  \n");
		sb.append("				    success : function(data, textStatus) {  \n");
		sb.append("				    	if(data.ajaxResult=='success'){ \n");
		sb.append("				    	  gridSearch();\n");
		sb.append("		            	  alert(\"分配成功！\");  \n"); 
		sb.append("		            	}else if(data.ajaxResult=='have'){  \n"); 
		sb.append("		            	  alert(\"存在已分配的项目！\");  \n"); 
		sb.append("		            	}else if(data.ajaxResult=='kong'){  \n"); 
		sb.append("				    	  gridSearch();\n");
		sb.append("		            	  alert(\"所选项目的检测室有空值！\");  \n"); 
		sb.append("		            	}\n"); 
		sb.append("				    }  \n");
		sb.append("		      });\n");
		sb.append("	}\n");
		//手动分配
		sb.append("		function fenpeiItem(){\n");
		sb.append("			var ids = $(\"#gridTableDept\").jqGrid(\"getGridParam\", \"selarrrow\") + \"\";\n");
		sb.append("		    if (!ids) {\n");
		sb.append("		    alert(\"请先选择记录!\");  \n");
		sb.append("		       return false;  \n");
		sb.append("			} \n");
		sb.append("	        if($(\"#orgId\").val()==\"\"){\n");
		sb.append("	        	alert(\"请先选择部门！\");\n");
		sb.append("		        return false;  \n");
		sb.append("		        }\n");
		sb.append("				if(!confirm(\"是否确认分配 ？\")){\n");
		sb.append("				   return false;\n");
		sb.append("			    }\n");
		sb.append("		     var ids1 = jQuery(\"#gridTableDept\").jqGrid('getDataIDs')+\"\"; \n");
		sb.append("		 	 if( ids1!=\"\" ){ \n");
		sb.append("					var arr = ids.split(\",\");\n");
		sb.append("					 	for(var i=0;i<arr.length;i++){\n");
		sb.append("					 		var row = jQuery(\"#gridTableDept\").jqGrid('getRowData',arr[i]);//获取选中行.\n");
		sb.append("			 				var deptId = row.DEPT_ID;\n");
		sb.append("							var projectState = row.PROJECT_STATE;\n");
		sb.append("							var ZHIBRUSERID = row.ZHIBRUSERID;\n");
		sb.append("							if(deptId!=\"\" && deptId!=null){\n");
		sb.append("		 						alert(\"存在已经分配的部门!\");\n");
		sb.append("		 						return false;\n");
		sb.append("		 					}\n");
		sb.append("							if(projectState!=\"调度\"  ){\n");
		sb.append("								alert(\"项目位置为调度的才可以分配!\");\n");
		sb.append("	                            return false;\n");
		sb.append("							}\n");
		sb.append("							if(ZHIBRUSERID==\"\"  ){\n");
		sb.append("								alert(\"请先分配值班人!\");\n");
		sb.append("	                            return false;\n");
		sb.append("							}\n");
		sb.append("						}\n");
		sb.append("		 	 }\n");
		sb.append("			 var params = {  \n");
		sb.append("			        \"ids\": ids,\n");
		sb.append("			        \"flag\": 2,\n");
		sb.append("			        \"mainid\": "+mainid+",\n");
		sb.append("			        \"orgid\" : $(\"#orgId\").val()\n");
		sb.append("			 };  \n");
		sb.append("			 var actionUrl = common_basePath+\"project/item!fenpeiDept.action\"; \n"); 
		sb.append("				    $.ajax({  \n");
		sb.append("				        url : actionUrl,  \n");
		sb.append("				        type : \"post\", \n");
		sb.append("				        data : params,  \n");
		sb.append("				        dataType : \"json\",  \n");
		sb.append("				        cache : false,  \n");
		sb.append("				    error : function(textStatus, errorThrown) {  \n");
		sb.append("				        alert(\"系统ajax交互错误: \" + textStatus.value);  \n");
		sb.append("				    },  \n");
		sb.append("				    success : function(data, textStatus) {  \n");
		sb.append("				    	if(data.ajaxResult=='success'){ \n");
		sb.append("				    	gridSearch();\n");
		sb.append("		            	alert(\"分配成功！\");  \n"); 
		sb.append("		            	}else if(data.ajaxResult=='have'){  \n"); 
		sb.append("		            	alert(\"存在已分配的项目！\");  \n"); 
		sb.append("		            	} \n"); 
		sb.append("				    }  \n");
		sb.append("		      });\n");
		sb.append("		}\n");
		sb.append("//查询\n");
		sb.append("		function gridSearch(){\n");
		sb.append("			var params = {  \n");
		sb.append("			};							 \n");
		sb.append("			 var postData = $(\"#gridTableDept\").jqGrid(\"getGridParam\", \"postData\");\n");
		sb.append("			 $.extend(postData, params);\n");
		sb.append("			jQuery(\"#gridTableDept\").jqGrid('setGridParam',\n");
		sb.append("			{\n");
		sb.append("url:common_basePath+'project/item!queryItem.action?mainid="+mainid+"'\n");
		sb.append("			}).trigger(\"reloadGrid\", [{page:1}]); \n");
		sb.append("	    }\n");
		sb.append("//下拉树选择组织\n");
		sb.append("function beforeClick(treeId, treeNode) {\n");
		sb.append("var check = (treeNode);//var check = (treeNode && !treeNode.isParent);只选择文件夹下面的\n");
		sb.append("    if (!check) alert(\"请选择具体的组织机构\");\n");
        sb.append("    return check;\n");
        sb.append(" }\n");
        sb.append(" function onClick(e, treeId, treeNode) {\n");
    	sb.append("     var zTree = $.fn.zTree.getZTreeObj(\"treeDemo\"),\n");
        sb.append("     nodes = zTree.getSelectedNodes(),\n");
        sb.append("     v = \"\";\n");
        sb.append("     o = \"\";\n");
        sb.append("     nodes.sort(function compare(a,b){return a.id-b.id;});\n");
        sb.append("     for (var i=0, l=nodes.length; i<l; i++) {\n");
    	sb.append("         v += nodes[i].name +\",\";\n");
        sb.append("         o += nodes[i].id + \",\";\n");
        sb.append("    }\n");
        sb.append("    if (v.length > 0 ) v = v.substring(0, v.length-1);\n");
        sb.append("    if (o.length > 0 ) o = o.substring(0, o.length-1);\n");
        sb.append("    var cityObj = $(\"#citySel\");\n");
        sb.append("   var orgId = $(\"#orgId\");\n");
        sb.append("   orgId.attr(\"value\",o);\n");
        sb.append("   cityObj.attr(\"value\", v);\n");
        sb.append("   hideMenu();\n");
        sb.append(" }\n");
        
        sb.append("function showMenu() {\n");
		sb.append("    if(!treeIsLoad){\n");
        sb.append("        showOrgTree();\n");
        sb.append("    }    \n");
        sb.append("    var cityObj = $(\"#citySel\");\n");
        sb.append("   var cityOffset = $(\"#citySel\").offset();\n");
        sb.append("   $(\"#menuContent\").css({left:cityOffset.left + \"px\", top:cityOffset.top + cityObj.outerHeight() + \"px\"}).slideDown(\"fast\");\n");
        sb.append("    $(\"body\").bind(\"mousedown\", onBodyDown);\n");
        sb.append(" }\n");
        sb.append(" function hideMenu() {\n");
    	sb.append("     $(\"#menuContent\").fadeOut(\"fast\");\n");
        sb.append("    $(\"body\").unbind(\"mousedown\", onBodyDown);\n");
        sb.append("}\n");
        sb.append(" function showOrgTree(){\n");
    	sb.append("    treeIsLoad = true;\n");
        sb.append("     var setting = {\n");
    	sb.append("        view: {\n");
    	sb.append("            dblClickExpand: false\n");
        sb.append("        },\n");
        sb.append("         data: {\n");
        sb.append("            simpleData: {\n");
        sb.append("                enable: true\n");
        sb.append("             }\n");
        sb.append("        },\n");
        sb.append("        callback: {\n");
        sb.append("            beforeClick: beforeClick,\n");
        sb.append("            onClick: onClick\n");
        sb.append("        }\n");
        sb.append("    };\n");
        sb.append("  var zNodes;\n");
        sb.append(" $.ajax({  \n");
        sb.append("        url : \"organization/searchAllOrg4.action\",  \n");
        sb.append("       type : \"post\", \n");
        sb.append("       dataType : \"json\",  \n");
        sb.append("       cache : false,  \n");
        sb.append("       async:false,\n");
        sb.append("       error : function(textStatus, errorThrown) {  \n");
        sb.append("           alert(\"系统ajax交互错误: \" + textStatus.value);  \n");
        sb.append("      },  \n");
        sb.append("      success : function(data, textStatus) {\n");
        sb.append("         zNodes = data;\n");
        sb.append("       } \n");
        sb.append("    });\n");
        sb.append("$.fn.zTree.init($(\"#treeDemo\"), setting, zNodes);\n");
        sb.append(" } \n");
        return sb.toString();
	}
	/**
	 * 获取js方法
	 * author:lishu	 2014-3-9
	 */
	public static String getUserJsFunction(String mainid,String deptid,String flowtaskinfoid){
		StringBuffer sb = new StringBuffer();
		//清空
		sb.append("		function deleteUser(){\n");
//		sb.append("			if(!confirm(\"是否确认清空人员?\")){\n");
//		sb.append("				 return false;\n");
//		sb.append("			}\n");
		sb.append("			var ids = $(\"#gridTableSampleItem\").jqGrid(\"getGridParam\", \"selarrrow\")+\"\";\n");
		sb.append("         if(!ids){\n");
		sb.append("          alert(\"请选择数据!\");");
		sb.append("          return false;");
		sb.append("          }\n ");
		sb.append("				 var params = {  \n");
		sb.append("			        \"ids\" :  ids,\n");
		sb.append("			        \"taskInfoId\" :"+flowtaskinfoid+"\n");
		sb.append("				 };  \n");
		sb.append("				        var actionUrl = common_basePath+\"project/item!deleteUser.action\"; \n"); 
		sb.append("				        $.ajax({  \n");
		sb.append("				            url : actionUrl,  \n");
		sb.append("				            type : \"post\", \n");
		sb.append("				        	data : params,  \n");
		sb.append("				        	dataType : \"json\",  \n");
		sb.append("				        	cache : false,  \n");
		sb.append("				    		error : function(textStatus, errorThrown) {  \n");
		sb.append("				       	 		alert(\"系统ajax交互错误: \" + textStatus.value);  \n");
		sb.append("				    		},  \n");
		sb.append("				    		success : function(data, textStatus) {  \n");
		sb.append("                                gridSearchSampleItem();\n");
		
		sb.append("		            			alert(\"清除成功！\");  \n"); 
		sb.append("				    		}  \n");
		sb.append("		        		});\n");
		sb.append("		 \n");
		sb.append("		 \n");
		sb.append("		} \n");
		
		sb.append("//查询\n");
		sb.append("		function gridSearchUser(){\n");
		sb.append("			var params = {  \n");
		sb.append("			};							 \n");
		sb.append("			 var postData = $(\"#gridTableUser\").jqGrid(\"getGridParam\", \"postData\");\n");
		sb.append("			 $.extend(postData, params);\n");
		sb.append("			jQuery(\"#gridTableUser\").jqGrid('setGridParam',\n");
		sb.append("			{\n");
		sb.append("url:common_basePath+'project/item!queryUserItem.action?mainid="+mainid+"'\n");
		sb.append("			}).trigger(\"reloadGrid\", [{page:1}]); \n");
		sb.append("	    }\n");
		//sb.append("		function gridSearchUserOther(){\n");
		//sb.append("			var params = {  \n");
		//sb.append("			};							 \n");
		//sb.append("			 var postData = $(\"#gridTableUser\").jqGrid(\"getGridParam\", \"postData\");\n");
		//sb.append("			 $.extend(postData, params);\n");
		//sb.append("			jQuery(\"#gridTableUser\").jqGrid('setGridParam',\n");
		//sb.append("			{\n");
		//sb.append("url:common_basePath+'project/item!queryUserItemOther.action?mainid="+mainid+"'\n");
		//sb.append("			}).trigger(\"reloadGrid\", [{page:1}]); \n");
		//sb.append("	    }\n");
		sb.append("//pid即为父节点\n");
		sb.append("function deptUsers(pid){\n");
		sb.append("	jQuery.post(common_basePath+'project/item!queryDeptUsers.action',\n");
		sb.append("			{\n");
		sb.append("			\"deptid\":pid\n");
		sb.append("			},\n");
		sb.append("			callDeptUsers,\n");
		sb.append("			\"json\"); \n");
		sb.append("}\n");
		sb.append("function callDeptUsers(json){\n");
		sb.append("	$(\"#fuserId\").empty(); //清空下拉框\n");
		sb.append("	$.each(json,function(entryIndex,entry){\n");
		sb.append("		var html = '';\n");
		sb.append("			html = '<option value=\"'+entry['id']+'\">' + entry['cloumnName'] + '</option>';   \n");
		sb.append("	    $('#fuserId').append(html);   \n");
		sb.append("    });\n");
		sb.append("}\n");
		
        return sb.toString();
	}
	public static String getYsjlTable(String mainid, String deptid,Long userseq,String view) {
		StringBuffer sb = new StringBuffer();
		sb.append("$(\"#gridTableYsjl\").jqGrid({\n");
		sb.append("	url:common_basePath+'project/item!queryYsjlItem.action?view="+view+"&mainid="+mainid+"&userseq="+userseq+"',\n");
		sb.append("	datatype: \"json\",\n");
		sb.append("	height: 150,\n");
		sb.append("	width: 800, \n");
		sb.append("	colNames:['ID','样品编号','项目组','检验项目','技术条件','所选部门','所选用户','检测结果','是否合格','原始记录名称','原始记录路径','是否电子签名'],\n");
		sb.append("	colModel:[\n");
		sb.append("	{name:'ID',index:'ID', width:40,key:true,hidden:true,hidedlg:true}, \n");
		sb.append("		{name:'SAMPLE_NO',index:'SAMPLE_NO', width:70}, \n");
		sb.append("		{name:'T_XMZ',index:'T_XMZ', width:150}, \n");
		sb.append("		{name:'T_JYXM',index:'T_JYXM', width:150}, \n");
		sb.append("		{name:'T_JSTJ',index:'T_JSTJ', width:150},\n");
		sb.append("		{name:'DEPT_ID',index:'DEPT_ID', width:100}, \n");
		sb.append("		{name:'USER_ID',index:'USER_ID', width:100},\n");
		sb.append("		{name:'ITEMRESULT',index:'ITEMRESULT', width:100},\n");
		sb.append("		{name:'T_PDYJ',index:'T_PDYJ', width:80, cellattr: function (rowId, val, rawObject, cm, rdata) {  " +
				        " var msg ='';" +
				        "if(rawObject.T_PDYJ=='不合格'){ " +
				        " msg = \"style='color:red'\";" +
				        "}" +
				        "return msg }},\n");
		sb.append("		{name:'YSJL_NAME',index:'YSJL_NAME', width:120}, \n");
		sb.append("		{name:'YSJL_PATH',index:'YSJL_PATH', width:120},\n");
		sb.append("		{name:'SFDIANZIQIANMIN',index:'SFDIANZIQIANMIN',hidden:true}\n");
		sb.append("	],   \n");
		sb.append("	shrinkToFit:false,\n");
		sb.append("	sortname:'ID',\n");
		sb.append("	sortorder:'desc',\n");
		sb.append("	viewrecords:true,\n");
		sb.append("	multiselect: true, // 是否显示复选框\n");
		sb.append("	multiboxonly : true, \n");
		sb.append("	rownumbers: false,//显示行号\n");
		sb.append("	editable:true, \n");
		sb.append("	rowNum:200,\n");
		sb.append("	rowList:[15,20,50,200,500],\n");
		//sb.append("	toolbar: [true,\"top\"],\n");
		sb.append("	jsonReader: {\n");
		sb.append("		root:\"rows\",		// 数据行（默认为：rows）\n");
		sb.append("		page: \"page\",  	// 当前页\n");
		sb.append("		total: \"total\",  // 总页数\n");
		sb.append("		records: \"records\",  // 总记录数\n");
		sb.append("		repeatitems : false		// 设置成false，在后台设置值的时候，可以乱序。且并非每个值都得设\n");
		sb.append("	},\n");
		sb.append("	prmNames:{rows:\"rows\",page:\"page\",sort:\"sidx\",order:\"sord\",search:\"search\"},\n");
		sb.append("	pager:\"#gridPagerYsjl\",\n");
		sb.append("postData : {\n");
		sb.append("	userseq:\""+userseq+"\"\n");
		sb.append("},\n");
		sb.append("	caption: \"原始记录项目列表\"\n");
		sb.append("});\n");
		//sb.append("$(\"#t_gridTableYsjl\").append(\"<input type='button'  value='编辑原始记录' onclick='openYsjl('1')' style='height:25px;font-size:-3'/>\");\n");
		//sb.append("$(\"#t_gridTableYsjl\").append(\"<input type='button' value='删除' style='height:25px;font-size:-3'/>\");\n");
		

		//sb.append("jQuery(\"#gridTableYsjl\").jqGrid('navGrid','#gridPagerYsjl',{edit:false,add:false,del:true,refresh:false,searchtext:\"编辑原始记录\"});\n");
		//sb.append("$(\"#gridTableYsjl\").jqGrid('navButtonAdd', '#gridPagerYsjl', { caption: \"Save\", onClickButton: function() { $(\"#btnSaveAs\").trigger(\"click\"); } });\n");
		//sb.append("deptUsers('"+deptid+"')\n");
		

		return sb.toString();
	}
	public static String getYsjlTable1(String mainid, String deptid,Long userseq,String view) {
		StringBuffer sb = new StringBuffer();
		sb.append("$(\"#gridTableYsjl1\").jqGrid({\n");
		sb.append("	url:common_basePath+'project/item!queryYsjlItem.action?view="+view+"&mainid="+mainid+"&userseq="+userseq+"',\n");
		sb.append("	datatype: \"json\",\n");
		sb.append("	height: 150,\n");
		sb.append("	width: 800, \n");
		sb.append("	colNames:['ID','样品编号','项目组','检验项目','检测结果','判定结果','技术条件','所选部门','所选用户','原始记录名称','原始记录路径','是否电子签名'],\n");
		sb.append("	colModel:[\n");
		sb.append("	{name:'ID',index:'ID', width:40,key:true,hidden:true,hidedlg:true}, \n");
		sb.append("		{name:'SAMPLE_NO',index:'SAMPLE_NO', width:70}, \n");
		sb.append("		{name:'T_XMZ',index:'T_XMZ', width:150}, \n");
		sb.append("		{name:'T_JYXM',index:'T_JYXM', width:150}, \n");
		sb.append("		{name:'ITEMRESULT',index:'ITEMRESULT', width:150}, \n");
		sb.append("		{name:'T_PDYJ',index:'T_PDYJ', width:150}, \n");
		sb.append("		{name:'T_JSTJ',index:'T_JSTJ', width:150},\n");
		sb.append("		{name:'DEPT_ID',index:'DEPT_ID', width:100}, \n");
		sb.append("		{name:'USER_ID',index:'USER_ID', width:100},\n");
		sb.append("		{name:'YSJL_NAME',index:'YSJL_NAME', width:120}, \n");
		sb.append("		{name:'YSJL_PATH',index:'YSJL_PATH', width:120},\n");
		sb.append("		{name:'SFDIANZIQIANMIN',index:'SFDIANZIQIANMIN',hidden:true}\n");
		sb.append("	],   \n");
		sb.append("	shrinkToFit:false,\n");
		sb.append("	sortname:'ID',\n");
		sb.append("	sortorder:'desc',\n");
		sb.append("	viewrecords:true,\n");
		sb.append("	multiselect: true, // 是否显示复选框\n");
		sb.append("	multiboxonly : true, \n");
		sb.append("	rownumbers: false,//显示行号\n");
		sb.append("	editable:true, \n");
		sb.append("	rowNum:200,\n");
		sb.append("	rowList:[15,20,50,200,500],\n");
		//sb.append("	toolbar: [true,\"top\"],\n");
		sb.append("	jsonReader: {\n");
		sb.append("		root:\"rows\",		// 数据行（默认为：rows）\n");
		sb.append("		page: \"page\",  	// 当前页\n");
		sb.append("		total: \"total\",  // 总页数\n");
		sb.append("		records: \"records\",  // 总记录数\n");
		sb.append("		repeatitems : false		// 设置成false，在后台设置值的时候，可以乱序。且并非每个值都得设\n");
		sb.append("	},\n");
		sb.append("	prmNames:{rows:\"rows\",page:\"page\",sort:\"sidx\",order:\"sord\",search:\"search\"},\n");
		sb.append("	pager:\"#gridPagerYsjl1\",\n");
		sb.append("	caption: \"原始记录项目列表\"\n");
		sb.append("});\n");
		//sb.append("$(\"#t_gridTableYsjl\").append(\"<input type='button'  value='编辑原始记录' onclick='openYsjl('1')' style='height:25px;font-size:-3'/>\");\n");
		//sb.append("$(\"#t_gridTableYsjl\").append(\"<input type='button' value='删除' style='height:25px;font-size:-3'/>\");\n");

		//sb.append("jQuery(\"#gridTableYsjl\").jqGrid('navGrid','#gridPagerYsjl',{edit:false,add:false,del:true,refresh:false,searchtext:\"编辑原始记录\"});\n");
		//sb.append("$(\"#gridTableYsjl\").jqGrid('navButtonAdd', '#gridPagerYsjl', { caption: \"Save\", onClickButton: function() { $(\"#btnSaveAs\").trigger(\"click\"); } });\n");
		//sb.append("deptUsers('"+deptid+"')\n");
		

		return sb.toString();
	}
	public static String getBgTable1(String mainid,String tableid, String deptid,Long userseq,String formid,Long taskId,String flowStateid,String view) {
		StringBuffer sb = new StringBuffer();
		sb.append("$(\"#gridTableBg1"+tableid+"\").jqGrid({\n");
		sb.append("	url:common_basePath+'project/item!queryBgItem.action?view="+view+"&mainid="+mainid+"&formid="+formid+"&userseq="+userseq+"&childTaskId="+taskId+"&flowStateid="+flowStateid+"',\n");
		sb.append("	datatype: \"json\",\n");
		sb.append("	height: 150,\n");
		sb.append("	width: 800, \n");
		sb.append("	colNames:['ID','检验项目','项目组','所选部门','所选用户','报告名称','报告路径','是否电子签名'],\n");
		sb.append("	colModel:[\n");
		sb.append("	{name:'ID',index:'ID', width:40,key:true,hidden:true,hidedlg:true}, \n");
		sb.append("		{name:'T_JYXM',index:'T_JYXM', width:150}, \n");
		sb.append("		{name:'T_XMZ',index:'T_XMZ', width:150},\n");
		sb.append("		{name:'DEPT_ID',index:'DEPT_ID', width:100}, \n");
		sb.append("		{name:'USER_ID',index:'USER_ID', width:100},\n");
		sb.append("		{name:'BG_NAME',index:'BG_NAME', width:120}, \n");
		sb.append("		{name:'BG_PATH',index:'BG_PATH', width:120},\n");
		sb.append("		{name:'SFDIANZIQIANMIN',index:'SFDIANZIQIANMIN',hidden:true}\n");
		sb.append("	],   \n");
		sb.append("	shrinkToFit:false,\n");
		sb.append("	sortname:'ID',\n");
		sb.append("	sortorder:'desc',\n");
		sb.append("	viewrecords:true,\n");
		sb.append("	multiselect: true, // 是否显示复选框\n");
		sb.append("	multiboxonly : true, \n");
		sb.append("	rownumbers: false,//显示行号\n");
		sb.append("	editable:true, \n");
		sb.append("	rowNum:200,\n");
		sb.append("	rowList:[15,20,50,200,500],\n");
		//sb.append("	toolbar: [true,\"top\"],\n");
		sb.append("	jsonReader: {\n");
		sb.append("		root:\"rows\",		// 数据行（默认为：rows）\n");
		sb.append("		page: \"page\",  	// 当前页\n");
		sb.append("		total: \"total\",  // 总页数\n");
		sb.append("		records: \"records\",  // 总记录数\n");
		sb.append("		repeatitems : false		// 设置成false，在后台设置值的时候，可以乱序。且并非每个值都得设\n");
		sb.append("	},\n");
		sb.append("	prmNames:{rows:\"rows\",page:\"page\",sort:\"sidx\",order:\"sord\",search:\"search\"},\n");
		sb.append("	pager:\"#gridPagerBg1"+tableid+"\",\n");
		sb.append("	caption: \"报告项目列表\"\n");
		sb.append("});\n");
		//sb.append("$(\"#t_gridTableYsjl\").append(\"<input type='button'  value='编辑原始记录' onclick='openYsjl('1')' style='height:25px;font-size:-3'/>\");\n");
		//sb.append("$(\"#t_gridTableYsjl\").append(\"<input type='button' value='删除' style='height:25px;font-size:-3'/>\");\n");

		//sb.append("jQuery(\"#gridTableYsjl\").jqGrid('navGrid','#gridPagerYsjl',{edit:false,add:false,del:true,refresh:false,searchtext:\"编辑原始记录\"});\n");
		//sb.append("$(\"#gridTableYsjl\").jqGrid('navButtonAdd', '#gridPagerYsjl', { caption: \"Save\", onClickButton: function() { $(\"#btnSaveAs\").trigger(\"click\"); } });\n");
		//sb.append("deptUsers('"+deptid+"')\n");
		

		return sb.toString();
	}
	public static String getBgTable(String mainid,String tableid, String deptid,Long userseq,Long taskId,String flowStateid,String view) {
		StringBuffer sb = new StringBuffer();
		sb.append("$(\"#gridTableBg"+tableid+"\").jqGrid({\n");
		sb.append("	url:common_basePath+'project/item!queryBgItem.action?view="+view+"&mainid="+mainid+"&userseq="+userseq+"&childTaskId="+taskId+"&flowStateid="+flowStateid+"',\n");
		sb.append("	datatype: \"json\",\n");
		sb.append("	height: 150,\n");
		sb.append("	width: 800, \n");
		sb.append("	colNames:['ID','检验项目','项目组','所选部门','所选用户','报告名称','报告路径','所选原始记录模版','是否电子签名'],\n");
		sb.append("	colModel:[\n");
		sb.append("	{name:'ID',index:'ID', width:40,key:true,hidden:true,hidedlg:true}, \n");
		sb.append("		{name:'T_JYXM',index:'T_JYXM', width:150}, \n");
		sb.append("		{name:'T_XMZ',index:'T_XMZ', width:150},\n");
		sb.append("		{name:'DEPT_ID',index:'DEPT_ID', width:100}, \n");
		sb.append("		{name:'USER_ID',index:'USER_ID', width:100},\n");
		sb.append("		{name:'BG_NAME',index:'BG_NAME', width:120}, \n");
		sb.append("		{name:'BG_PATH',index:'BG_PATH', width:120},\n");
		sb.append("		{name:'FILE_NAME',index:'FILE_NAME', width:120},\n");
		sb.append("		{name:'SFDIANZIQIANMIN',index:'SFDIANZIQIANMIN',hidden:true}\n");
		sb.append("	],   \n");
		sb.append("	shrinkToFit:false,\n");
		sb.append("	sortname:'ID',\n");
		sb.append("	sortorder:'desc',\n");
		sb.append("	viewrecords:true,\n");
		sb.append("	multiselect: true, // 是否显示复选框\n");
		sb.append("	multiboxonly : true, \n");
		sb.append("	rownumbers: false,//显示行号\n");
		sb.append("	editable:true, \n");
		sb.append("	rowNum:200,\n");
		sb.append("	rowList:[15,20,50,200,500],\n");
		//sb.append("	toolbar: [true,\"top\"],\n");
		sb.append("	jsonReader: {\n");
		sb.append("		root:\"rows\",		// 数据行（默认为：rows）\n");
		sb.append("		page: \"page\",  	// 当前页\n");
		sb.append("		total: \"total\",  // 总页数\n");
		sb.append("		records: \"records\",  // 总记录数\n");
		sb.append("		repeatitems : false		// 设置成false，在后台设置值的时候，可以乱序。且并非每个值都得设\n");
		sb.append("	},\n");
		sb.append("	prmNames:{rows:\"rows\",page:\"page\",sort:\"sidx\",order:\"sord\",search:\"search\"},\n");
		sb.append("	pager:\"#gridPagerBg"+tableid+"\",\n");
		sb.append("postData : {\n");
		sb.append("	userseq:\""+userseq+"\"\n");
		sb.append("},\n");
		sb.append("	caption: \"报告项目列表\"\n");
		sb.append("});\n");
		//sb.append("$(\"#t_gridTableYsjl\").append(\"<input type='button'  value='编辑原始记录' onclick='openYsjl('1')' style='height:25px;font-size:-3'/>\");\n");
		//sb.append("$(\"#t_gridTableYsjl\").append(\"<input type='button' value='删除' style='height:25px;font-size:-3'/>\");\n");

		//sb.append("jQuery(\"#gridTableYsjl\").jqGrid('navGrid','#gridPagerYsjl',{edit:false,add:false,del:true,refresh:false,searchtext:\"编辑原始记录\"});\n");
		//sb.append("$(\"#gridTableYsjl\").jqGrid('navButtonAdd', '#gridPagerYsjl', { caption: \"Save\", onClickButton: function() { $(\"#btnSaveAs\").trigger(\"click\"); } });\n");
		//sb.append("deptUsers('"+deptid+"')\n");
		

		return sb.toString();
	}
	public static String getYsjlJsFunction(String valueOf, String deptid) {
		// TODO Auto-generated method stub
		return null;
	}
	
	/**
	 * 
	 * 描述：常规检测流程中样品列表
	 * @author wangxd
	 * @date Jun 30, 2015 4:39:08 PM
	 * @return String
	 * @throw
	 */
	public static String getSampleTable(String taskId){
		StringBuffer sb = new StringBuffer();
		sb.append("$(\"#gridTableSample\").jqGrid({\n");
		sb.append("	url:common_basePath+'autoForms/item!querySampleByTaskId.action?taskId="+taskId+"',\n");
		sb.append("	datatype: \"json\",\n");
		sb.append("	height: 150,\n");
		sb.append("	width: 720, \n");
		sb.append("	colNames:['主键','样品名称','样品数量','样品编号','批次号/规格型号','应用车型','整车型号','生产商','约定送样日期','样品处理','附件'],\n");
		sb.append("	colModel:[\n");
		sb.append("		{name:'ID',index:'ID', width:70,key:true,hidden:true}, \n");
		sb.append("		{name:'T_SAMPLENAME',index:'T_SAMPLENAME', width:100}, \n");
		sb.append("		{name:'T_SAMPLECOUNT',index:'T_SAMPLECOUNT', width:50}, \n");
		sb.append("		{name:'T_SAMPLENO',index:'T_SAMPLENO', width:140,hidden:true}, \n");
		sb.append("		{name:'T_PICI',index:'T_PICI', width:70}, \n");
		sb.append("		{name:'T_YINGYONGCHEXING',index:'T_YINGYONGCHEXING', width:80}, \n");
		sb.append("		{name:'T_CHEXINGBIANMA',index:'T_CHEXINGBIANMA', width:70}, \n");
		sb.append("		{name:'T_MANUFACTURER',index:'T_MANUFACTURER', width:70},\n");
		sb.append("		{name:'T_SONGYANGDATE',index:'T_SONGYANGDATE', width:70},\n");
		sb.append("		{name:'T_SAMPLECHULI',index:'T_SAMPLECHULI', width:70},\n");
		sb.append("     {name:'FILE_NAME',index:'FILE_NAME', width:180,hidden:true,hidedlg:false,formatter: function(cellvalue, options, rowObject) {");
		sb.append("        return \"<a href='javascript:downloafAnnex(0,\"+rowObject.T_ANNEX+\")'>\"+rowObject.FILE_NAME+\"</a>\" }}");
		sb.append("	],   \n");
		sb.append("	shrinkToFit:false,\n");
		sb.append("	sortname:'ID',\n");
		sb.append("	sortorder:'asc',\n");
		sb.append("	viewrecords:true,\n");
		sb.append("	multiselect: true, // 是否显示复选框\n");
		sb.append("	multiboxonly : true, \n");
		sb.append("	rownumbers: false,//显示行号\n");
		sb.append(" cellEdit: false,\n");
		sb.append("	forceFit : true, \n");
		sb.append("	rowNum:200,\n");
		sb.append("	mtype: \"POST\", \n");
		sb.append("	rowList:[15,20,50,200,500],\n");
		sb.append("	toolbar: [false,\"top\"],\n");
		sb.append("	jsonReader: {\n");
		sb.append("		root:\"rows\",		// 数据行（默认为：rows）\n");
		sb.append("		page: \"page\",  	// 当前页\n");
		sb.append("		total: \"total\",  // 总页数\n");
		sb.append("		records: \"records\",  // 总记录数\n");
		sb.append("		repeatitems : false		// 设置成false，在后台设置值的时候，可以乱序。且并非每个值都得设\n");
		sb.append("	},\n");
		sb.append("	prmNames:{rows:\"rows\",page:\"page\",sort:\"sidx\",order:\"sord\",search:\"search\"},\n");
		sb.append("	pager:\"#gridPagerSample\",\n");
		sb.append("	caption: \"样品列表\"\n");
		sb.append("});\n");

		return sb.toString();
	} 
	
	/**
	 * 
	 * 描述：常规检测流程中检测项目列表
	 * @author wangxd
	 * @date Jun 30, 2015 4:39:08 PM
	 * @return String
	 * @throw
	 */
	public static String getItemeTable(String taskId,String type,String specialType){
		StringBuffer sb = new StringBuffer();
		//type 0：常规检测流程发起节点选择检测项目 1：常规检测流程发起节点其他检测项目  空：其他节点查询检测项目
		sb.append("var lastsel3;");
		sb.append("$(\"#gridTableItem1\").jqGrid({\n");
		sb.append("	url:common_basePath+'autoForms/item!queryItemByTaskId.action?type="+type+"&taskId="+taskId+"',\n");
		sb.append("	datatype: \"json\",\n");
		sb.append("	height: 150,\n");
		sb.append("	width: 720, \n");
		sb.append("	colNames:['ID','检测项目','标准数量','标准委托','报告形式','报告要求','附件名称','检测费用','检测标准'],\n");
		sb.append("	colModel:[\n");
		sb.append("		{name:'ID',index:'ID', width:70,key:true,hidden:true}, \n");
		sb.append("		{name:'T_ITEMNAME',index:'T_ITEMNAME', width:180}, \n");
		sb.append("		{name:'bzcount',index:'bzcount', width:70,hidden:true}, \n");
		sb.append("		{name:'T_BIAOZHUNWEITUO',index:'T_BIAOZHUNWEITUO', width:80,editable: true,edittype:'select',editoptions:{value:'否:否;是:是'},formatter: function (cellvalue, options, rowObject) {\n");
		sb.append("			if(rowObject.bzcount>0){ \n");
		sb.append("				biaozhunweituo='否';\n");
		sb.append("				}else{ \n");
		sb.append("					biaozhunweituo='是';\n");
		sb.append("				}\n");
		sb.append("				return biaozhunweituo;\n");
		sb.append("	       }},\n");
		sb.append("		{name:'T_BAOGAOTYPE',index:'T_BAOGAOTYPE', width:100,editable:true,edittype:'select',editoptions:{value:'出具检测报告:出具检测报告;出具原始记录:出具原始记录',dataEvents:[");
		sb.append("        {type: 'change',fn: function(e) { \n");
	    sb.append("			    var bgtype = $(this).val(); \n" );
	    sb.append("			    var rowid = $(this).parent().parent().attr('ID');\n" );
	    sb.append("         	if(bgtype=='出具原始记录'){ \n");
	    sb.append("                jQuery(\"#gridTableItem1\").jqGrid('setRowData',rowid,{T_BGYAOQIU:''});");
	    sb.append(" 	        } ");
	    sb.append("         	else if(bgtype=='出具检测报告'){\n");
	    sb.append("                var msg = '<select class=\"editable\" id=\"'+rowid+'_T_BGYAOQIU\" submitName=\"T_BGYAOQIU\" role=\"select\" size=\"1\"><option role=\"option\" value=\"中文\">中文</option><option role=\"option\" value=\"英文\">英文</option><option role=\"option\" value=\"中英文\">中英文</option></select>';");
	    sb.append("                $(\"#gridTableItem1\").jqGrid('setCell',rowid,'T_BGYAOQIU',msg); ");
	    sb.append(" 	        } ");
	    sb.append("        }}]}}, \n");
		
		sb.append("		{name:'T_BGYAOQIU',index:'T_BGYAOQIU', width:80,editable: true,edittype:'select',editoptions:{value:'中文:中文;英文:英文;中英文:中英文'}}, \n");
		sb.append("     {name:'FILE_NAME',index:'FILE_NAME', width:180,hidden:true,hidedlg:false,formatter: function(cellvalue, options, rowObject) {");
		sb.append("        return \"<a href='javascript:downloafAnnex(0,\"+rowObject.T_ANNEX+\")'>\"+rowObject.FILE_NAME+\"</a>\" }},");
		sb.append("		{name:'T_JIANCEMONEY',index:'T_JIANCEMONEY', width:80}, \n");
		sb.append("		{name:'T_JIANCEBIAOZHUN',index:'T_JIANCEBIAOZHUN', width:200} \n");
		sb.append("	],   \n");
		if("1".equals(specialType)){
			sb.append("onSelectRow: function(id){\n");
//			sb.append("   if(id && id!==lastsel3){\n");
			sb.append("      jQuery('#gridTableItem1').jqGrid('editRow',id,true);\n");
			sb.append("      lastsel3=id;\n");
//			sb.append("   }\n");
			sb.append("}, \n");
		}
		
		sb.append("	shrinkToFit:false,\n");
		sb.append("	sortname:'T_ITEMID',\n");
		sb.append("	sortorder:'asc',\n");
		sb.append("	viewrecords:true,\n");
		sb.append("	multiselect: true, // 是否显示复选框\n");
		sb.append("	multiboxonly : true, \n");
		sb.append("	rownumbers: false,//显示行号\n");
		sb.append(" cellEdit: false,\n");
		sb.append("	forceFit : true, \n");
		sb.append("	rowNum:200,\n");
		sb.append("	mtype: \"POST\", \n");
		sb.append("	rowList:[15,20,50,200,500],\n");
		sb.append("	toolbar: [false,\"top\"],\n");
		sb.append("	jsonReader: {\n");
		sb.append("		root:\"rows\",		// 数据行（默认为：rows）\n");
		sb.append("		page: \"page\",  	// 当前页\n");
		sb.append("		total: \"total\",  // 总页数\n");
		sb.append("		records: \"records\",  // 总记录数\n");
		sb.append("		repeatitems : false		// 设置成false，在后台设置值的时候，可以乱序。且并非每个值都得设\n");
		sb.append("	},\n");
		sb.append("	prmNames:{rows:\"rows\",page:\"page\",sort:\"sidx\",order:\"sord\",search:\"search\"},\n");
		sb.append("	pager:\"#gridPagerItem1\",\n");
//		sb.append("subGrid: true,\n");
//		sb.append("subGridRowExpanded: function(subgrid_id, row_id) { \n");
//		sb.append("      var rowData = $(\"#gridTableItem1\").getRowData(row_id); \n");
//		sb.append("      var subgrid_table_id; \n");
//		sb.append("      subgrid_table_id = subgrid_id+\"_t\"; \n");
//		sb.append("      var row = jQuery(\"#gridTableItem1\").jqGrid('getRowData',row_id);\n");
//		sb.append("      jQuery(\"#\"+subgrid_id).html(\"<table id='\"+subgrid_table_id+\"' class='scroll'></table>\");\n");
//		sb.append("      jQuery(\"#\"+subgrid_table_id).jqGrid({ \n");
//		sb.append("       url:common_basePath+'autoForms/item!queryItemBiaozhunByItemId.action?tableName=GWM_JIANCEBZ_FLOW&taskId="+taskId+"&itemId='+row_id+'&temp='+Math.round(Math.random()*10000), \n");
//		sb.append("       datatype: \"json\", \n");
//	    sb.append("       colNames:['ID','检测标准'],\n");
//		sb.append("       colModel:[ \n");
//        sb.append("          {name:'ID',index:'ID', width:100,key:true,hidden:true, sorttype:\"int\"} , \n");
//		sb.append("          {name:'T_JIANCEBIAOZHUN',index:'T_JIANCEBIAOZHUN', width:200} \n");
//		sb.append("       ], \n");
//		sb.append("       jsonReader: { \n");
//        sb.append("       root:\"rows\",		// 数据行（默认为：rows） \n");
//		sb.append("       page: \"page\",  	// 当前页 \n");
//		sb.append("       total: \"total\",  // 总页数 \n");
//		sb.append("       records: \"records\",  // 总记录数  \n");
//		sb.append("       repeatitems : false		// 设置成false，在后台设置值的时候，可以乱序。且并非每个值都得设  \n");
//		sb.append("       },  \n");
//		sb.append("       shrinkToFit:false,\n");
//		sb.append("       multiselect: true,\n");
//		sb.append("       height:\"auto\", \n"); 
//	    sb.append("       width:300,\n");
//	    sb.append("       rowNum:500,\n");
//		sb.append("       sortname:'ID', \n");
//		sb.append("       sortorder:'asc' \n");
//		sb.append(" }); \n");
//		sb.append("  }, \n");
		sb.append("	caption: \"检测项目列表\"\n");
		sb.append("});\n");

		return sb.toString();
	} 
	
	/**
	 * 
	 * 描述：其他检测项目列表
	 * @author wangxd
	 * @date Jul 7, 2015 3:48:47 PM
	 * @return String
	 * @throw
	 */
	public static String getItemeTable2(String taskId){
		StringBuffer sb = new StringBuffer();
		sb.append("var lastsel3;");
		sb.append("$(\"#gridTableItem2\").jqGrid({\n");
		sb.append("	url:common_basePath+'autoForms/item!queryItemByTaskId.action?type=1&taskId="+taskId+"',\n");
		sb.append("	datatype: \"json\",\n");
		sb.append("	height: 150,\n");
		sb.append("	width: 720, \n");
		sb.append("	colNames:['主键','检测项目','标准委托','报告形式','报告要求','附件名称','项目ID'],\n");
		sb.append("	colModel:[\n");
		sb.append("		{name:'ID',index:'ID', width:70,key:true,hidden:true}, \n");
		sb.append("		{name:'T_ITEMNAME',index:'T_ITEMNAME', width:180}, \n");
		sb.append("		{name:'T_BIAOZHUNWEITUO',index:'T_BIAOZHUNWEITUO', width:80,editable: true,edittype:'select',editoptions:{value:'否:否;是:是'}},\n");
		sb.append("		{name:'T_BAOGAOTYPE',index:'T_BAOGAOTYPE', width:180,editable: true,edittype:'select',editoptions:{value:'出具检测报告:出具检测报告;出具原始记录:出具原始记录',dataEvents:[");
		sb.append("        {type: 'change',fn: function(e) { \n");
	    sb.append("			    var bgtype = $(this).val();\n" );
	    sb.append("             var rowid = $(this).parent().parent().attr('ID');");
	    sb.append("             $(\"gridTableItem2\").jqGrid('setSelection',rowid);");
	    sb.append("         	if(bgtype=='出具原始记录'){ \n");
//	    sb.append("                var rowid = $(\"#gridTableItem2\").jqGrid(\"getGridParam\", \"selarrrow\")+\"\";");
	    sb.append("                jQuery(\"#gridTableItem2\").jqGrid('setRowData',rowid,{T_BGYAOQIU:''});");
	    sb.append(" 	        } ");
	    sb.append("         	else if(bgtype=='出具检测报告'){\n");
//	    sb.append("                var rowid = $(\"#gridTableItem2\").jqGrid(\"getGridParam\", \"selarrrow\")+\"\"; ");
	    sb.append("                var msg = '<select class=\"editable\" id=\"'+lastsel3+'_T_BGYAOQIU\" submitName=\"T_BGYAOQIU\" role=\"select\" size=\"1\"><option role=\"option\" value=\"中文\">中文</option><option role=\"option\" value=\"英文\">英文</option><option role=\"option\" value=\"中英文\">中英文</option></select>';");
	    sb.append("                $(\"#gridTableItem2\").jqGrid('setCell',rowid,'T_BGYAOQIU',msg); ");
	    sb.append(" 	        } ");
	    sb.append("        }}]}}, \n");
		sb.append("		{name:'T_BGYAOQIU',index:'T_BGYAOQIU', width:80,editable: true,edittype:'select',editoptions:{value:'中文:中文;英文:英文;中英文:中英文'}}, \n");
		sb.append("     {name:'FILE_NAME',index:'FILE_NAME', width:180,hidden:false,hidedlg:false,formatter: function(cellvalue, options, rowObject) {");
		sb.append("        return \"<a href='javascript:downloafAnnex(0,\"+rowObject.T_ANNEX+\")'>\"+rowObject.FILE_NAME+\"</a>\"}},");
		sb.append("		{name:'ITEMFLOWID',index:'ITEMFLOWID', width:180,hidden:true} \n");
		sb.append("	],   \n");
		sb.append("onSelectRow: function(id){ \n");
//		sb.append("   if(id && id!==lastsel3){\n");
		sb.append("      jQuery('#gridTableItem2').jqGrid('editRow',id,true);\n");
		sb.append("      lastsel3=id;\n");
//		sb.append("   }\n");
		sb.append("}, \n");
		sb.append("	shrinkToFit:false,\n");
		sb.append("	sortname:'ID',\n");
		sb.append("	sortorder:'asc',\n");
		sb.append("	viewrecords:true,\n");
		sb.append("	multiselect: true, // 是否显示复选框\n");
		sb.append("	multiboxonly : true, \n");
		sb.append("	rownumbers: false,//显示行号\n");
		sb.append(" cellEdit: false,\n");
		sb.append("	forceFit : true, \n");
		sb.append("	rowNum:200,\n");
		sb.append("	mtype: \"POST\", \n");
		sb.append("	rowList:[15,20,50,200,500],\n");
		sb.append("	toolbar: [false,\"top\"],\n");
		sb.append("	jsonReader: {\n");
		sb.append("		root:\"rows\",		// 数据行（默认为：rows）\n");
		sb.append("		page: \"page\",  	// 当前页\n");
		sb.append("		total: \"total\",  // 总页数\n");
		sb.append("		records: \"records\",  // 总记录数\n");
		sb.append("		repeatitems : false		// 设置成false，在后台设置值的时候，可以乱序。且并非每个值都得设\n");
		sb.append("	},\n");
		sb.append("	prmNames:{rows:\"rows\",page:\"page\",sort:\"sidx\",order:\"sord\",search:\"search\"},\n");
		sb.append("	pager:\"#gridPagerItem2\",\n");
		sb.append("	caption: \"其他检测项目列表\"\n");
		sb.append("});\n");

		return sb.toString();
	} 
	/**
	 * 
	 * 描述：常规检测流程中样品/检测项目列表
	 * @author wangxd
	 * @date Jul 16, 2015 10:14:12 AM
	 * @return String
	 * @throw
	 */
	public static String getGwmItemSampleTableByTaskId(String taskId,String stateId,String deptId,String flowtaskinfoid,String reportsftj){
		
		String type="";
		String sortName = "ID";
		String flagValue = "true";
		String sfxianshi = "true";
		String sfshenhe = "true";   //是否审核列显示
		if("txysjl".equals(stateId) || "bgbz".equals(stateId) || "shysjl".equals(stateId) || "bgsh".equals(stateId)
				|| "bgpz".equals(stateId) || "bgqz".equals(stateId) || "bgysjlff".equals(stateId)){
			flagValue = "false";
		}
		if("ksrwfp".equals(stateId)||"syrwjs".equals(stateId)){
			type ="0";
			sortName ="T_SAMPLENO";
		}
		//原始记录节点 显示检测参数
		if("txysjl".equals(stateId)){
			sfxianshi = "false";
		}
		else if("shysjl".equals(stateId)){
			sfshenhe = "false";
		}
		StringBuffer sb = new StringBuffer();
		sb.append("$(\"#gridTableSampleItem\").jqGrid({\n");
		sb.append("	url:common_basePath+'autoForms/item!queryItemSampleByTaskId.action?type="+type+"&taskId="+taskId+"&stateId="+stateId+"&flowtaskinfoid="+flowtaskinfoid+"&reportsftj="+reportsftj+"',\n");
		sb.append("	datatype: \"json\",\n");
		sb.append("	height: 150,\n");
		sb.append("	width: 720, \n");
		
		//报告审核列表显示字段
	    if("bgsh".equals(stateId)){
	      sb.append("  colNames:['主键','报告名称','报告识别号','报告是否审核','原始记录名称','记录是否审核','检测项目','样品编号','是否有附件','查看附件','原始记录路径','报告路径'],\n");
	      sb.append("  colModel:[\n");
	      sb.append("    {name:'ID',index:'ID', width:70,key:true,hidden:true}, \n");
	      sb.append("    {name:'BGFILENAME',index:'BGFILENAME', width:110}, \n");
	      sb.append("    {name:'T_REPORTSHIBIEH',index:'T_REPORTSHIBIEH', width:80}, \n");
	      sb.append("    {name:'T_REPORTSFQIANMING',index:'T_REPORTSFQIANMING', width:65}, \n");
	      sb.append("    {name:'YSJLNAME',index:'YSJLNAME', width:110}, \n");
	      sb.append("    {name:'T_SFDIANZIQIANM',index:'T_SFDIANZIQIANM', width:65}, \n");
	      sb.append("    {name:'T_ITEMNAME',index:'T_ITEMNAME', width:120}, \n");
	      sb.append("    {name:'T_SAMPLENO',index:'T_SAMPLENO', width:100}, \n");
	      sb.append("    {name:'ISHAVEFILE',index:'ISHAVEFILE', width:60}, \n");
	      sb.append("    {name:'UPLOADFILE',index:'UPLOADFILE',width:80}, \n");
	      sb.append("    {name:'T_YSJLFILEPATH',index:'T_YSJLFILEPATH', width:130,hidden:true},\n");
	      sb.append("	 {name:'T_BGFILEPATH',index:'T_BGFILEPATH',hidden:true, width:80} \n");
	      sb.append("  ],   \n");
	    }
	    //报告批准节点显示字段
	    else   if("bgpz".equals(stateId)){
	      sb.append("  colNames:['主键','报告名称','报告识别号','报告是否批准','原始记录名称','检测项目','样品编号','是否有附件','查看附件','原始记录路径','报告路径'],\n");
	      sb.append("  colModel:[\n");
	      sb.append("    {name:'ID',index:'ID', width:70,key:true,hidden:true}, \n");
	      sb.append("    {name:'BGFILENAME',index:'BGFILENAME', width:110}, \n");
	      sb.append("    {name:'T_REPORTSHIBIEH',index:'T_REPORTSHIBIEH', width:100}, \n");
	      sb.append("    {name:'T_REPORTSFQIANMING',index:'T_REPORTSFQIANMING', width:65}, \n");
	      sb.append("    {name:'YSJLNAME',index:'YSJLNAME', width:110}, \n");
	      sb.append("    {name:'T_ITEMNAME',index:'T_ITEMNAME', width:120}, \n");
	      sb.append("    {name:'T_SAMPLENO',index:'T_SAMPLENO', width:100}, \n");
	      sb.append("    {name:'ISHAVEFILE',index:'ISHAVEFILE', width:60}, \n");
	      sb.append("    {name:'UPLOADFILE',index:'UPLOADFILE',width:80}, \n");
	      sb.append("    {name:'T_YSJLFILEPATH',index:'T_YSJLFILEPATH', width:130,hidden:true},\n");
	      sb.append("	 {name:'T_BGFILEPATH',index:'T_BGFILEPATH',hidden:true, width:80} \n");
	      sb.append("  ],   \n");
	    }
	    //报告签章节点显示字段
	    else   if("bgqz".equals(stateId)){
	      sb.append("  colNames:['主键','报告名称','报告识别号','报告是否签章','原始记录名称','检测项目','样品编号','报告路径'],\n");
	      sb.append("  colModel:[\n");
	      sb.append("    {name:'ID',index:'ID', width:70,key:true,hidden:true}, \n");
	      sb.append("    {name:'BGFILENAME',index:'BGFILENAME', width:110}, \n");
	      sb.append("    {name:'T_REPORTSHIBIEH',index:'T_REPORTSHIBIEH', width:80}, \n");
	      sb.append("    {name:'T_REPORTSFQIANMING',index:'T_REPORTSFQIANMING', width:65}, \n");
	      sb.append("    {name:'YSJLNAME',index:'YSJLNAME', width:110}, \n");
	      sb.append("    {name:'T_ITEMNAME',index:'T_ITEMNAME', width:120}, \n");
	      sb.append("    {name:'T_SAMPLENO',index:'T_SAMPLENO', width:100},\n");
	      sb.append("	 {name:'T_BGFILEPATH',index:'T_BGFILEPATH',hidden:true, width:80} \n");
	      sb.append("  ],   \n");
	    }
	    //报告发放节点显示字段
	    else   if("bgysjlff".equals(stateId)){
	      sb.append("  colNames:['主键','报告名称','报告识别号','原始记录名称','检测项目','样品编号','报告路径'],\n");
	      sb.append("  colModel:[\n");
	      sb.append("    {name:'ID',index:'ID', width:70,key:true,hidden:true}, \n");
	      sb.append("    {name:'BGFILENAME',index:'BGFILENAME', width:150}, \n");
	      sb.append("    {name:'T_REPORTSHIBIEH',index:'T_REPORTSHIBIEH', width:100}, \n");
	      sb.append("    {name:'YSJLNAME',index:'YSJLNAME', width:150}, \n");
	      sb.append("    {name:'T_ITEMNAME',index:'T_ITEMNAME', width:180}, \n");
	      sb.append("    {name:'T_SAMPLENO',index:'T_SAMPLENO', width:120}, \n");
	      sb.append("	 {name:'T_BGFILEPATH',index:'T_BGFILEPATH',hidden:true, width:80} \n");
	      sb.append("  ],   \n");
	    }
	    else{
			sb.append("	colNames:['主键','检测类别','检测项目','检测参数','原始记录名称','记录是否审核','检测标准','样品编号','检测人员','报告识别号','报告是否审核','报告要求','样品附件','检测项目附件','样品附件ID','项目附件ID','MAINID','是否有附件','','操作'],\n");
			sb.append("	colModel:[\n");
			sb.append("		{name:'ID',index:'ID', width:70,key:true,hidden:true}, \n");
			sb.append("		{name:'T_JIACELEIBIE',index:'T_JIACELEIBIE', width:90}, \n");
			sb.append("		{name:'T_ITEMNAME',index:'T_ITEMNAME', width:120}, \n");
			sb.append("		{name:'T_JIANCECANSHU',index:'T_JIANCECANSHU', width:100,hidden:"+sfxianshi+"}, \n");
			sb.append("		{name:'T_YSJLFILEPATH',index:'T_YSJLFILEPATH', width:130}, \n");
			sb.append("		{name:'T_SFDIANZIQIANM',index:'T_SFDIANZIQIANM', width:65,hidden:"+sfshenhe+"}, \n");
			sb.append("		{name:'T_JIANCEBIAOZHUN',index:'T_JIANCEBIAOZHUN', width:100}, \n");
			sb.append("		{name:'T_SAMPLENO',index:'T_SAMPLENO', width:100}, \n");
			sb.append("		{name:'T_JIANCEYUANNAME',index:'T_JIANCEYUANNAME', width:80}, \n");
			sb.append("		{name:'T_REPORTSHIBIEH',index:'T_REPORTSHIBIEH', width:80,hidden:true}, \n");
			sb.append("		{name:'T_REPORTSFQIANMING',index:'T_REPORTSFQIANMING', width:65,hidden:true}, \n");
			sb.append("		{name:'T_BAOGAOTYPE',index:'T_BAOGAOTYPE', width:80}, \n");
			sb.append("     {name:'SAMPLE_FILE_NAME',index:'SAMPLE_FILE_NAME', width:180,hidden:true,hidedlg:false,formatter: function(cellvalue, options, rowObject) {");
			sb.append("        return \"<a href='javascript:downloafAnnex(0,\"+rowObject.ST_ANNEX+\")'>\"+rowObject.SAMPLE_FILE_NAME+\"</a>\" }},");
			sb.append("     {name:'ITEM_FILE_NAME',index:'ITEM_FILE_NAME', width:180,hidden:true,hidedlg:false,formatter: function(cellvalue, options, rowObject) {");
			sb.append("        return \"<a href='javascript:downloafAnnex(0,\"+rowObject.IT_ANNEX+\")'>\"+rowObject.ITEM_FILE_NAME+\"</a>\"}},");
			sb.append("		{name:'ST_ANNEX',index:'ST_ANNEX', width:140,hidden:true}, \n");
			sb.append("		{name:'IT_ANNEX',index:'IT_ANNEX', width:140,hidden:true}, \n");
			sb.append("		{name:'MAINID',index:'MAINID', width:80,hidden:true}, \n");
			sb.append("		{name:'ISHAVEFILE',index:'ISHAVEFILE',hidden:"+flagValue+", width:60}, \n");
			sb.append("		{name:'T_BGFILEPATH',index:'T_BGFILEPATH',hidden:true, width:80}, \n");
			sb.append("		{name:'UPLOADFILE',index:'UPLOADFILE',hidden:"+flagValue+", width:80} \n");
			sb.append("	],   \n");
	    }
		sb.append("	shrinkToFit:false,\n");
		sb.append("	sortname:'"+sortName+"',\n");
		sb.append("	ondblClickRow:function(id){ rowselect(id); },\n");
		sb.append("	sortorder:'asc',\n");
		sb.append("	viewrecords:true,\n");
		sb.append("	multiselect: true, // 是否显示复选框\n");
		sb.append("	multiboxonly : true, \n");
		sb.append("	rownumbers: false,//显示行号\n");
		sb.append(" cellEdit: false,\n");
		sb.append("	forceFit : true, \n");
		sb.append("	rowNum:200,\n");
		sb.append("	mtype: \"POST\", \n");
		sb.append("	rowList:[15,20,50,200,500],\n");
		sb.append("	toolbar: [false,\"top\"],\n");
		sb.append("	jsonReader: {\n");
		sb.append("		root:\"rows\",		// 数据行（默认为：rows）\n");
		sb.append("		page: \"page\",  	// 当前页\n");
		sb.append("		total: \"total\",  // 总页数\n");
		sb.append("		records: \"records\",  // 总记录数\n");
		sb.append("		repeatitems : false		// 设置成false，在后台设置值的时候，可以乱序。且并非每个值都得设\n");
		sb.append("	},\n");
		sb.append("	prmNames:{rows:\"rows\",page:\"page\",sort:\"sidx\",order:\"sord\",search:\"search\"},\n");
		sb.append("	pager:\"#gridPagerSampleItem\",\n");
		sb.append("	caption: \"样品/检测项目列表\",\n");
		sb.append("	gridComplete:function(){ //在此事件中循环为每一行添加修改和删除链接 \",\n");
		sb.append("var ids=jQuery(\"#gridTableSampleItem\").jqGrid('getDataIDs');\n");
		sb.append("for(var i=0; i<ids.length; i++){ \n");
		sb.append("var id=ids[i];\n");
		if("txysjl".equals(stateId)){
			sb.append("modify =\"<a href='#' style='color:#f60' onclick='ysjlFile(\"+ id +\")'>上传附件</a>\";\n");
		}else{
			sb.append("modify =\"<a href='#' style='color:#f60' onclick='ysjlFile(\"+ id +\")'>查看附件</a>\";\n");
		}
		sb.append("jQuery(\"#gridTableSampleItem\").jqGrid('setRowData', ids[i], { UPLOADFILE: modify });\n");
		sb.append("}}\n");
		sb.append("});\n");
		sb.append("deptUsers('"+deptId+"');\n");
		return sb.toString();
	}
	
	
	public static String getUploadHtml(String contextPath, String id, String column, String isshow){
		StringBuffer sb = new StringBuffer();
		sb.append("<link href=\""+contextPath+"/fileupload/wbox/wbox.css\" type=\"text/css\" rel=\"stylesheet\"/>\n");
		sb.append("<script type=\"text/javascript\" src=\""+contextPath+"/fileupload/wbox/wbox.js\"></script>\n");
		sb.append("	<style type=\"text/css\">\n");
			sb.append("   		html{\n");
		   			sb.append("		    overflow-x: hidden;\n");
		   		sb.append("		}  	\n");
		   		sb.append("		.ellipsis{overflow:hidden;white-space:nowrap;text-overflow:ellipsis;width: 150px}\n");
				sb.append("   </style>\n");
		   sb.append("<script type=\"text/javascript\">\n");
		//sb.append("var show = '"+isshow+"';\n");
		sb.append("var wBox"+column+"=$(\"#show_box"+column+"\").wBox({noTitle:true,title:\"附件上传\",requestType:\"iframe\",iframeWH:{width:450,height:300},target:\""+contextPath+"/fileupload/file_upload.jsp?code_id="+id+"&column="+column+"\"});\n");
		sb.append("	$(document).ready(function(){	\n");
				sb.append("		var params = {\n");
						sb.append("			\"code_id\" : '"+id+"',\n");
								sb.append("			\"column\" : '"+column+"'\n");
						sb.append("		};\n");
				sb.append("		var actionUrl = \"tdmAttachment!getAttachments.action\";\n");
				sb.append("		$.ajax({\n");
					sb.append("			url : actionUrl,\n");
					sb.append("			type : \"post\",\n");
					sb.append("			data : params,\n");
					sb.append("			dataType : \"text\",\n");
					sb.append("			cache : false,\n");
					sb.append("			success : function(data, textStatus) {\n");
					sb.append("				if (data != \"error\") {\n");
							sb.append("					var json = eval(data);\n");
							sb.append("					for(var i=0; i<json.length; i++) \n");
								sb.append("					{ \n");
								sb.append("						var $table=$(\"#tab"+column+" tr\");\n");
								sb.append("						var len=$table.length; \n");
								sb.append("						if(\""+isshow+"\"==\"n\"){\n");
									sb.append("						$(\"#tab"+column+"\").append(\"<tr id=\"+(len+1)+\"><td align=\'left\'><a href=\'#\' onclick=deltr"+column+"(\'\"+(len+1)+\"\',\'\"+json[i].id+\"\')><image src="+contextPath+"/fileupload/image/cancel.png /></a></td><td align=\'left\' width=\'30px\'><div class=\'ellipsis\'><a href="+contextPath+"/FileDownloadServlet?id=\"+json[i].id+\" title=\"+json[i].fileName+\">\"+json[i].fileName+\"</a></div></td><td align=\'left\'>\"+bytesToSize(json[i].fileLength)+\"</td></tr>\");			\n");
									sb.append("						}else if(\""+isshow+"\" == \"y\"){\n");
									sb.append("							$(\"#tab"+column+"\").append(\"<tr id=\"+(len+1)+\"><td align=\'left\'><a href=\'#\' onclick=deltr"+column+"(\'\"+(len+1)+\"\',\'\"+json[i].id+\"\')><image src="+contextPath+"/fileupload/image/cancel.png style=\'display:none;\' /></a></td><td align=\'left\' width=\'30px\'><div class=\'ellipsis\'><a href="+contextPath+"/FileDownloadServlet?id=\"+json[i].id+\" title=\"+json[i].fileName+\">\"+json[i].fileName+\"</a></div></td><td align=\'left\'>\"+bytesToSize(json[i].fileLength)+\"</td></tr>\");		\n");	
									sb.append("						}\n");
								sb.append("					} \n");
							sb.append("				} else {\n");
							sb.append("				}\n");
						sb.append("			}\n");
				sb.append("		});\n");
				sb.append("		$(\"#upload"+column+"\").click(function(){\n");
					sb.append("			 wBox"+column+".showBox();\n");
					 sb.append("		})\n");
				sb.append("	})\n");
		sb.append("	function addRow"+column+"(returnStr){\n");
				sb.append("		if(returnStr!=null && returnStr !=\"\"){\n");
					sb.append("			var fileList  = returnStr.split(\"|\");\n");
					sb.append("			for(i=0;i<fileList.length;i++){\n");
						sb.append("				var jsonObj = eval('(' + fileList[i] + ')');\n");
						sb.append("				var $table=$(\"#tab"+column+" tr\");\n");
						sb.append("				var len=$table.length; \n");
						sb.append("				$(\"#tab"+column+"\").append(\"<tr id=\"+(len+1)+\"><td align=\'left\'><a href=\'#\' onclick=deltr"+column+"(\'\"+(len+1)+\"\',\'\"+jsonObj.ID+\"\')><image src="+contextPath+"/fileupload/image/cancel.png /></a></td><td align=\'left\' width=\'30px\'><div class=\'ellipsis\'><a href="+contextPath+"/FileDownloadServlet?id=\"+jsonObj.ID+\" title=\"+jsonObj.filename+\">\"+jsonObj.filename+\"</a></div></td><td align=\'left\'>\"+bytesToSize(jsonObj.filelength)+\"</td></tr>\");		\n");	
						sb.append("			}\n");
					sb.append("		 }\n");
				sb.append("	}\n");
			sb.append("	  /*附件大小格式处理*/\n");
			sb.append("    function bytesToSize(bytes) {\n");
		    	sb.append("		    if (bytes === 0) return '0 B';\n");
				    sb.append("		    var k = 1024, // or 1024\n");
				    		sb.append(" 		        sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],\n");
				        		sb.append("		        i = Math.floor(Math.log(bytes) / Math.log(k));\n");
				    sb.append("		   return (bytes / Math.pow(k, i)).toPrecision(3) + ' ' + sizes[i];\n");
				   sb.append("		}\n");
		    sb.append("	function deltr"+column+"(index,ID)\n");
		sb.append("	{\n");
				sb.append("		$table=$(\"#tab"+column+" tr\");\n");
				sb.append("		if(index>$table.length)\n");
					sb.append("			return;\n");
				sb.append("		else\n");
					sb.append("		{\n");
					sb.append("			if(ID!=null && ID!=\"\"){\n");
						sb.append("				var params = {\n");
								sb.append("					\"id\" : ID\n");
								sb.append("				};\n");
						sb.append("				var actionUrl = \"tdmAttachment!deleteAttachment.action\";\n");
							sb.append("				$.ajax({\n");
								sb.append("						url : actionUrl,\n");
								sb.append("						type : \"post\",\n");
								sb.append("						data : params,\n");
								sb.append("						dataType : \"json\",\n");
								sb.append("						cache : false,\n");
								sb.append("						success : function(data, textStatus) {\n");
								sb.append("							if (data.ajaxResult == \"success\") {\n");
										sb.append("								$(\"#tab"+column+" tr[id=\'\"+index+\"\']\").remove();	\n");
										sb.append("							} else {\n");
										sb.append("								alert(\"删除失败,请重试!\");\n");
										sb.append("							}\n");
									sb.append("						}\n");
							sb.append("					});\n");
							sb.append("			}\n");
					sb.append("		}	\n");
				sb.append("	}\n");
			sb.append("</script>\n");
		sb.append("<div id=\"show_box"+column+"\"></div>\n");
		sb.append("<input type=\"hidden\" id=\"filecount"+column+"\" value=\"0\"/>\n");
		if("n".equals(isshow)){
			sb.append("<image src=\""+contextPath+"/fileupload/image/attach.png\" /><a  id=\"upload"+column+"\" href=\"#\">添加附件</a><br>");
		}
		sb.append("<table id=\"tab"+column+"\" border=\"0\" width=\"60%\" align=\"left\">\n");
		sb.append("</table>\n");
		return sb.toString();
	}
	
}
